<?php
namespace Application\Entity;


use Doctrine\ORM\Mapping as ORM;
use Application\Repository\UserRepository;

/**
 * User
 *
 * @ORM\Entity(repositoryClass="Application\Repository\UserRepository") @ORM\Table(name="user")
 */
class User
{
    /**
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @ORM\Id
     * @ORM\Column(name="uid", type="bigint", nullable=false)
     */
    public $uid;

    /**
     * @var string
     *
     * @ORM\Column(name="firstname", type="string", length=255, nullable=true)
     */
    public $firstname;

    /**
     * @var string
     *
     * @ORM\Column(name="lastname", type="string", length=255, nullable=true)
     */
    public $lastname;
    
    /**
     * @var string
     *
     * @ORM\Column(name="middlename", type="string", length=255, nullable=true)
     */
    public $middlename;
    
    /**
     * @var string
     *
     * @ORM\Column(name="picwithlogo", type="string", length=255, nullable=true)
     */
    public $picwithlogo;

    
    /**
     * @var string
     *
     * @ORM\Column(name="sex", type="string", length=255, nullable=true)
     */
    public $sex;
    
    
    /**
     * @var string
     *
     * @ORM\Column(name="username", type="string", length=255, nullable=true)
     */
    public $username;
    
    /**
     * @var string
     *
     * @ORM\Column(name="password", type="string", length=255, nullable=true)
     */
    public $password;
    /**
     * @var string
     *
     * @ORM\Column(name="local", type="string", length=255, nullable=true)
     */
    public $locale;
    
    /**
     * @var string
     *
     * @ORM\Column(name="currency", type="string", length=255, nullable=true)
     */
    public $currency;

    /**
     * @var string
     *
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
     */
    public $email;

    /**
     * @var string
     *
     * @ORM\Column(name="key_password", type="string", length=255, nullable=true)
     */
    public $keyPassword;
    
    /**
     * @var \DateTime
     *
     * @ORM\Column(name="date_password", type="datetime", nullable=true)
     */
    public $datePassword;
    /**
     * @var string
     *
     * @ORM\Column(name="occupation", type="string", length=255, nullable=true)
     */
    public $occupation;
    
    /**
     * @var string
     *
     * @ORM\Column(name="aboutme", type="string", length=255, nullable=true)
     */
    public $aboutme;
    
    /**
     * @var string
     *
     * @ORM\Column(name="token", type="string", length=255, nullable=true)
     */
    public $token;
    

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="valid_token", type="datetime", nullable=true)
     */
    public $valid_token;
    
    
    /**
     * @var \DateTime
     *
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
     */
    public $createdAt;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="modified_at", type="datetime", nullable=false)
     */
    public $modifiedAt;

    /**
     * @var \Provider
     *
     * @ORM\ManyToOne(targetEntity="Application\Entity\Country")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="country", referencedColumnName="code")
     * })
     */
    public $country;
    
    /**
     * @var \Provider
     *
     * @ORM\ManyToOne(targetEntity="Application\Entity\City")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="city", referencedColumnName="name"),
     *   @ORM\JoinColumn(name="country", referencedColumnName="country"),
     *   @ORM\JoinColumn(name="province", referencedColumnName="province")
     * })
     */
    public $city;
    
    /**
     * @var \Provider
     *
     * @ORM\ManyToOne(targetEntity="Application\Entity\UserFacebook", fetch="EAGER")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="user_facebook_uid", referencedColumnName="uid")
     * })
     */
    public $userFacebook;

    /**
     * @var string
     *
     * @ORM\Column(name="key_confirm", type="string", length=255, nullable=true)
     */
    public $keyConfirm;

    /**
     * @var string
     *
     * @ORM\Column(name="confirm", type="boolean", nullable=true)
     */
    public $confirm;
    
    /**
     * @var \DateTime
     *
     * @ORM\Column(name="confirm_at", type="datetime" , nullable=true)
     */
    public $confirmAt;
    
    public function getJson(){
        $result = array(
        	"uid"=>$this->uid,
            "lastname"=>$this->lastname==null?"":$this->lastname,
            "firstname"=>$this->firstname==null?"":$this->firstname,
            "middlename"=>$this->middlename==null?"":$this->middlename,
            "occupation"=>$this->occupation==null?"":$this->occupation,
            "aboutme"=>$this->aboutme==null?"":$this->aboutme,
            "photo"=>$this->picwithlogo==null?"user.png":$this->picwithlogo,
            "email"=>$this->email==null?"":$this->email,
        );
        return $result;
    }
}
